//
//  PaySeatViewController.m
//  PeopleStreet
//
//  Created by 辰领科技 on 16/3/24.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "PaySeatViewController.h"

@interface PaySeatViewController ()
@property (strong, nonatomic) IBOutlet UIView *messageView;
@property (strong, nonatomic) IBOutlet UIButton *messageButton;
@property (strong, nonatomic) IBOutlet UIButton *maskButton;

@property (strong, nonatomic) IBOutlet UIScrollView *scroView;
@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UIView *noticeView;
@property (strong, nonatomic) IBOutlet UIView *payButtonView;
@property (strong, nonatomic) IBOutlet UILabel *payLeftTime;


@property (strong, nonatomic) IBOutlet UILabel *movieName;
@property (strong, nonatomic) IBOutlet UILabel *filmAddress;
@property (strong, nonatomic) IBOutlet UILabel *moviePlace;
@property (strong, nonatomic) IBOutlet UILabel *playTime;


@property (strong, nonatomic) IBOutlet UILabel *smallCountMoney;
@property (strong, nonatomic) IBOutlet UILabel *totalPrice; //小计后的总价


@property (strong, nonatomic) IBOutlet UILabel *tiePhone;//绑定的手机号


@property (strong, nonatomic) IBOutlet UILabel *secondTotalPrice;//第二个总价


@property (strong, nonatomic) IBOutlet UILabel *leftToPay;//还需支付


@property (strong, nonatomic) IBOutlet UIButton *payButton;


@property(nonatomic,strong)NSTimer * timer;
@property(nonatomic,assign)NSInteger  time;


@end

@implementation PaySeatViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _time = 900;
    [self initViewLayout];
    // Do any additional setup after loading the view.
}


- (void)initViewLayout{
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.scroView];
    [self adaptiveViewLayout:self.noticeView];
    [self adaptiveViewLayout:self.payButtonView];
    [self adaptiveViewLayout:self.messageView];
     self.messageView.layer.cornerRadius = 6*VerticalRatio();
     self.messageButton.layer.cornerRadius = 3*VerticalRatio();
    self.payButton.layer.cornerRadius = 3*VerticalRatio();
    self.scroView.contentSize = flexibleSize(CGSizeMake(0, 575), YES);
    
    
    NSString *subtotalStr = [NSString stringWithFormat:@"(含服务费￥3元/张)"];
    NSString *Str = [NSString stringWithFormat:@"小计 %@",subtotalStr];
    NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:Str];
    [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithWhite:0.525 alpha:1.000] range:NSMakeRange(noteStr.length-subtotalStr.length, subtotalStr.length)];
    [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(noteStr.length-subtotalStr.length, subtotalStr.length)];
    
    [self.smallCountMoney setAttributedText:noteStr];
    

}

- (IBAction)back:(id)sender {
    [self.navigationController  popViewControllerAnimated:YES];
}

#pragma mark == 我知道了
- (IBAction)iKnowHandel:(id)sender {
    _maskButton.hidden = YES;
    _messageView.hidden = YES;
    _timer =  [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(changeTime) userInfo:nil repeats:YES];
    [self startTimer];
}


#pragma mark   == 绑定新手机号
- (IBAction)tieNewPhone:(id)sender {
}

#pragma mark   == 使用抵用卷
- (IBAction)useMoneyPaper:(id)sender {
}


#pragma mark -- Timer

- (void)changeTime{
    _time --;
    NSInteger min = _time/60;
    NSInteger sec = _time%60;
    NSString * string = [NSString stringWithFormat:@"支付剩余时间: %ld:%ld",min,sec];
    NSMutableAttributedString * str = [[NSMutableAttributedString alloc]initWithString:string];
    [str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithWhite:0.282 alpha:1.000] range:NSMakeRange(0, 8)];
    _payLeftTime.attributedText = str;
    if (_time == 0) {
        [self stopTimer];
    }
}

- (void)startTimer{
    [_timer fire];
}

- (void)stopTimer{
    [_timer invalidate];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
